package com.bdqn.wang.controller;


import com.alibaba.fastjson.JSON;
import com.bdqn.wang.pojo.User;
import com.bdqn.wang.service.UserService;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import javax.annotation.Resource;

@Controller
@RequestMapping("/user")
public class UserController {

    @Resource
    private UserService userService;

    @RequestMapping(value = "/toLogin")
    public String index(){
        return "login";
    }

    @RequestMapping(value = "/login")
    @ResponseBody
    public String doLogin(User user) {
        User user1 = userService.loginUser(user);
        if (user1!=null){
             return JSON.toJSONString("true");
        }else{
            return JSON.toJSONString("false");
        }
    }
    @RequestMapping(value = "/index.html")
    public  String toIndex(){
        return "index";
    }
    @RequestMapping(value="/user.html")
    public String toUserList() {
        return "user";
    }

    @RequestMapping(value="/useradd.html")
    public String toUserAdd() {
        return "useradd";
    }
    @RequestMapping( value="/userdetail.html")
    public String toUserDel(){
        return "userdetail";
    }

    @RequestMapping( value="/useredit.html")
    public String toUserupdate(){
        return "useredit";
    }

}



